package com.vm.action.mobile;


import java.util.Map;
import org.apache.log4j.Logger;
import com.opensymphony.xwork2.Preparable;
import com.vm.action.ActionSuper;
import com.vm.common.Page;
import com.vm.dao.mobile.base.IMobileAppManageDao;
import com.vm.dao.mobile.base.ISmsDetailDao;
import com.vm.entity.SmsDetail;
import com.vm.log4j.CustomizeLog4j;

public class SmsDetailAction extends ActionSuper implements Preparable {
	
	private static Logger log = CustomizeLog4j.getLogger(SmsDetailAction.class);
	
	private Page<SmsDetail> page;
	private SmsDetail smsDetail;
	private ISmsDetailDao smsDetailDao;
	private IMobileAppManageDao mobileAppManageDao;
	private Map<String,String> sectionMap;
	private String pageLinkList;
	private Integer businessId;
	private Integer id;
	
	
	public void prepare() throws Exception {
//		sectionMap = this.mobileAppManageDao.getSelectPoMap("select bkId as id,bkName as name from Section");
		//atuo
	}
	
	public String list(){
		this.page = this.smsDetailDao.getSmsByBusinessId(businessId,this.PAGE_ROW_SIZE, super.getPageNumber());
		this.pageLinkList =super.getSplitPageLink("/mobile/SmsDetailAction_list.do?", this.page);
		return SUCCESS;
	}
	
	public String add() throws Exception {
		if(this.smsDetail != null){
			smsDetail = null;
		}
		return SUCCESS;
	}

	public String save() throws Exception {
		String[] msgArg = new String[] { "SmsDetailAction_list.do"};
		String msg = null;
		try {
			smsDetailDao.save(smsDetail);
			msg = super.getResourceMessage("insert_smsDetail_success", msgArg);
		} catch (Exception e) {
			log.error("SmsDetailAction save smsDetail error", e);
			msg = super.getResourceMessage("insert_smsDetail_err", msgArg);
		}
		super.setShowMessage(msg);
		return super.SHOW_MESSAGE_RESULT;
	}

	public String edit(){
		smsDetail = smsDetailDao.findById(this.getId());
		return SUCCESS;
	}

	public String update() throws Exception {
		String[] msgArg = new String[] { "SmsDetailAction_list.do"};
		String msg = null;
		try {
			smsDetailDao.update(smsDetail);
			msg = super.getResourceMessage("update_smsDetail_success", msgArg);
		} catch (Exception e) {
			log.error("SmsDetailAction save smsDetail error  ", e);
			msg = super.getResourceMessage("update_smsDetail_err", msgArg);
		}
		super.setShowMessage(msg);
		return super.SHOW_MESSAGE_RESULT;

	}

	public String delete() {
		String[] msgArg = new String[] { "SmsDetailAction_list.do"};
		String msg = null;
		try {
			smsDetailDao.deleteById(this.getId());
			msg = super.getResourceMessage("delete_smsDetail_success", msgArg);
		} catch (Exception e) {
			log.error("SmsDetailAction delete smsDetail error  ", e);
			msg = super.getResourceMessage("delete_smsDetail_err", msgArg);
		}
		super.setShowMessage(msg);
		return super.SHOW_MESSAGE_RESULT;
	}

	public Page<SmsDetail> getPage() {
		return page;
	}

	public void setPage(Page<SmsDetail> page) {
		this.page = page;
	}

	

	public String getPageLinkList() {
		return pageLinkList;
	}

	public void setPageLinkList(String pageLinkList) {
		this.pageLinkList = pageLinkList;
	}

	public IMobileAppManageDao getMobileAppManageDao() {
		return mobileAppManageDao;
	}

	public void setMobileAppManageDao(IMobileAppManageDao mobileAppManageDao) {
		this.mobileAppManageDao = mobileAppManageDao;
	}

	public Map<String, String> getSectionMap() {
		return sectionMap;
	}

	public void setSectionMap(Map<String, String> sectionMap) {
		this.sectionMap = sectionMap;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public SmsDetail getSmsDetail() {
		return smsDetail;
	}

	public void setSmsDetail(SmsDetail smsDetail) {
		this.smsDetail = smsDetail;
	}

	public ISmsDetailDao getSmsDetailDao() {
		return smsDetailDao;
	}

	public void setSmsDetailDao(ISmsDetailDao smsDetailDao) {
		this.smsDetailDao = smsDetailDao;
	}

	public Integer getBusinessId() {
		return businessId;
	}

	public void setBusinessId(Integer businessId) {
		this.businessId = businessId;
	}

	
}
